//
//  SelectContactTableViewHeadModel.m
//  OAProject
//
//  Created by yhj on 2017/3/10.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "SelectContactTableViewHeadModel.h"

@implementation SelectContactTableViewCellModel

+(instancetype)selectContactTableViewCellModelWithDic:(NSDictionary *)dic
{
    SelectContactTableViewCellModel *cellModel=[[SelectContactTableViewCellModel alloc]initSelectContactTableViewCellModelWithDic:dic];
    return cellModel;
}

-(instancetype)initSelectContactTableViewCellModelWithDic:(NSDictionary *)dic
{
    if (self = [super init])
    {
        self.contactName=dic[@"user_name"];
        self.user_id = dic[@"user_id"];
    }
    return self;
}


@end

@implementation SelectContactTableViewHeadModel

+(instancetype)selectContactTableViewHeadModelWithDic:(NSDictionary *)dic
{
    SelectContactTableViewHeadModel *model=[[SelectContactTableViewHeadModel alloc]initSelectContactTableViewHeadModelWithDic:dic];
    model.name=dic[@"group_name"];
    return model;
}


-(instancetype)initSelectContactTableViewHeadModelWithDic:(NSDictionary *)dic{
    if (self= [super init]) {

        NSMutableArray *mutableArr = [NSMutableArray array];
        NSInteger value=0;
        NSInteger sum=0;
        NSString *ids;
        for (NSDictionary *dicCd  in dic[@"users"]) {
            SelectContactTableViewCellModel *cdModel=[SelectContactTableViewCellModel selectContactTableViewCellModelWithDic:dicCd];

//            value = [cdModel.cdPrice integerValue];
            sum = sum+value;
            ids=[cdModel.user_id stringByAppendingString:@","];
            [mutableArr addObject:cdModel];
        }
        
        self.sectionTotalPrice=sum;
        self.ids=ids;
        self.detailDateArr=mutableArr;
        NSLog(@"sectionTotalPrice  %zd",self.sectionTotalPrice);

        NSLog(@"agdgdgwyy---%@",self.ids);
    }
    return self;
}

- (NSMutableArray *)recordCellModelSelected
{
    if (!_recordCellModelSelected) {
        _recordCellModelSelected = [NSMutableArray array];
    }
    return _recordCellModelSelected;
}

@end

@implementation SelectContactTableViewModel

+(instancetype)selectContactTableViewModelWithArr:(NSArray *)arr
{
    SelectContactTableViewModel *model=[[SelectContactTableViewModel alloc]initWithSelectContactTableViewModelWithArr:arr];
    return model;
}

-(instancetype)initWithSelectContactTableViewModelWithArr:(NSArray *)arr
{
    if (self==[super init])
    {
        NSMutableArray *mutableArr=[NSMutableArray array];

        for (NSDictionary *dic in arr)
        {
            SelectContactTableViewHeadModel *detailModel = [SelectContactTableViewHeadModel selectContactTableViewHeadModelWithDic:dic];
            [mutableArr addObject:detailModel];
            self.recordArr = [NSMutableArray array];
        }
        self.headModelArr = mutableArr;

    }
    return self;
}

@end
